﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
namespace WPFExcelReport
{
    /// <summary>
    /// 用于显示规则
    /// 当需求改变时，重置规则
    /// 根据实际生产单，重置规则
    /// </summary>
    public partial class TFVKRULES
    { 
        public TFVKRULES()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            InitializeComponent();
         }
        public override void TextBox_KeyDown(object sender, KeyEventArgs e)
        {
            TextBox tb = sender as TextBox;
            tb.Text = tb.Text.Trim(); 
        }
        

        public override void OnWorkflowIDChange(ReflectionStudio.Core.Events.MessageEventArgs e)
        {
            base.OnWorkflowIDChange(e);
            MessageInfo msg = e.Info;
            string task = msg.MSGTYPE;
            switch (task)
            {
                case "RELOADRULE":
                    LOADBYAUF(msg.ORDER);
                    break;
            }
        }
        public override void Reset()
        {
            base.Reset();
            if (dwVKK == null)
            {
                return;
            }
            dwMaster["DELDATE"] = MV.date;
            string OVERSHORT = dwVKK["OVERSHORT"].ToString();
            int idxstart = OVERSHORT.IndexOfAny(new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' });
            int idxend = OVERSHORT.LastIndexOfAny(new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' });
            if (idxend > 0)
            {
                OVERSHORT = OVERSHORT.Substring(idxend, 1);
            }

            if (OVERSHORT.Trim().Length == 0)
            {
                OVERSHORT = "0";
            }
            dwMaster["R01"] = OVERSHORT;  
        } 
        private void btnResetP_Click(object sender, RoutedEventArgs e)
        {
            Reset();
        } 
    }
}
